package com.liyuhan.onlinetaxibackground.Controller;

import com.liyuhan.onlinetaxibackground.Service.LoginService;
import com.liyuhan.onlinetaxibackground.dto.DataResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;

@RestController
@RequestMapping("/login")
public class LoginController {
    @Autowired
    private LoginService loginService;

    @RequestMapping("/normalLogin")
    public DataResponse normalLogin(@Valid @RequestBody String request) {
        // 手机号+密码登录
        return loginService.loginWithPsw(request);
    }

    @RequestMapping("/verifyCodeLogin")
    public DataResponse verifyCodeLogin(@Valid @RequestBody String request) {
        // 手机号+短信验证码登录
        return loginService.loginWithVerifyCode(request);
    }

    @RequestMapping("/isLogin")
    public DataResponse isLogin(@Valid @RequestBody String request) {
        // 判断手机号对应的用户是否处于登录状态
        return loginService.isLogin(request);
    }

    @RequestMapping("/exit")
    public void exit(@Valid @RequestBody String request) {
        loginService.exit(request);
    }
}
